﻿Imports System
Imports System.Windows.Forms
Imports System.Data


Public Class FrmNam
    Private intNam As Nullable(Of Integer)
    Private intMaxNam As Nullable(Of Integer)
    ''' <summary>
    ''' Khống chế giới hạn năm 
    ''' </summary>
    ''' <value></value>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Property MaxNam() As Nullable(Of Integer)
        Get
            Return intMaxNam
        End Get
        Set(ByVal value As Nullable(Of Integer))
            intMaxNam = value
        End Set
    End Property

    Public Property Nam() As Nullable(Of Integer)
        Get
            Return intNam
        End Get
        Set(ByVal value As Nullable(Of Integer))
            intNam = value
        End Set
    End Property


    Private Sub FrmNam_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        If (e.Modifiers = GetKeyModifide("EXIT") And _
     e.KeyCode = GetKeyCode2("EXIT")) Or _
     (e.KeyCode = GetKeyCode("EXIT")) Then
            btnHuyBo_Click(Nothing, Nothing)
        End If

        If (e.Modifiers = GetKeyModifide("ACCEPT") And _
     e.KeyCode = GetKeyCode2("ACCEPT")) Or _
     (e.KeyCode = GetKeyCode("ACCEPT")) Then

            If btnChapNhan.Enabled = True And btnChapNhan.Visible = True Then
                btnChapNhan_Click(Nothing, Nothing)
            End If

        End If
    End Sub

    Private Sub FrmThangNamBaoCao_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'btnChapNhan.Image = Global.Publics.My.Resources.ResourceManager.GetObject("ok")
        'btnHuyBo.Image = Global.Publics.My.Resources.ResourceManager.GetObject("cancel")
        'spinNam.Text = Year(dbVms.GetDateTimeServer)
        spinNam.EditValue = vIntKTNam
        btnChapNhan.Text = BtnAcceptCaption
        btnHuyBo.Text = BtnCancelCaption
        spinNam.Focus()
        If MaxNam <> 0 Then
            spinNam.Properties.MaxValue = MaxNam
        Else
            spinNam.Properties.MaxValue = 3000
        End If
        Me.KeyPreview = True
    End Sub

    Private Sub btnHuyBo_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnHuyBo.Click
        intNam = 0
        Me.Close()
    End Sub

    Private Sub spinNam_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles spinNam.KeyDown
        If e.KeyCode = Keys.Enter Then
            btnChapNhan.Select()
        End If
    End Sub

    Private Sub btnChapNhan_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnChapNhan.Click
        intNam = CInt(spinNam.Text)
        Me.Close()
    End Sub
 
End Class